package com.demo.jfinal.model;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.redis.Redis;


public class GatewayAccept extends Model<GatewayAccept> {

	private static final long serialVersionUID = -3649555563326235483L;

	// 方便于访问数据库，不是必须
	public static final GatewayAccept dao = new GatewayAccept();

	/**
	 * 分页查询数据，jfinal使用原生sql处理数据,会节省解析性能
	 * 
	 * @param pageNumber
	 * @param pageSize
	 * @return
	 */
	public Page<GatewayAccept> paginate(int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select * ", "from blog order by id asc");
	}

	public GatewayAccept getfirstTest() {
		return dao.findFirst("select * from sms_gateway_interface where PHONE_NO = '18566783696' "); // 降序
	}

	
	/**
	 * 添加或者更新缓存
	 */
	public void cacheAdd(String ids) {
		GatewayAccept user = GatewayAccept.dao.findById(ids);
		Redis.use("SGIP").set("gatewayConfig" + ids, user);
	}

}
